/**
 * 〈功能简述〉<br>
 * 〈〉
 *
 * @author LiJunYi
 * @create 2019/7/5
 * @since 1.0.0
 */
package com.ljy.system.marvel_sys.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ljy.system.marvel_sys.system.dao.UserRoleDao;
import com.ljy.system.marvel_sys.system.model.user.UserRole;
import com.ljy.system.marvel_sys.system.service.IUserRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class UserRoleServiceImpl implements IUserRoleService {

    @Resource
    UserRoleDao userRoleDao;

    @Override
    public List<UserRole> listUserRoles(int userId) {
        long uId = (long) userId;
       return userRoleDao.selectList(new QueryWrapper<UserRole>().lambda().eq(UserRole::getUserId, uId));
    }

    @Override
    public int upateUserRole(long roleId, long userId) {
        return userRoleDao.update(null, Wrappers.<UserRole>lambdaUpdate().set(UserRole::getRoleId, roleId).eq(UserRole::getUserId,userId));
    }
}
